package com.project.controller;


import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("user")
@RestController
public class UserController {

    @PostMapping("login")
    public boolean login(String userName,String pwd){
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken user = new UsernamePasswordToken(userName,pwd);
        try {
            subject.login(user);
            return true;
        }
        catch (Exception e){
            return false;
        }
    }
}
